package com.project.hqshorttaxi.controller;

import com.github.pagehelper.PageHelper;
import com.project.hqshorttaxi.aop.TagLog;
import com.project.hqshorttaxi.dto.OperationLogParam;
import com.project.hqshorttaxi.service.OperationLogService;
import com.project.hqshorttaxi.util.PageInfo;
import com.project.hqshorttaxi.util.RestResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/operationlog/")
public class OperationLogController {

    @Resource
    OperationLogService operationLogService;

    /**
     * 列表
     */
    @PostMapping("page")
    @TagLog(operation = 0, content = "查询手动操作记录列表")
    public RestResult page(@RequestBody OperationLogParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        return RestResult.ok(new PageInfo<>(operationLogService.list(param)));
    }

    /**
     * 根据ID获取
     */
    @GetMapping("{id}")
    @TagLog(operation = 0, content = "根据ID获取手动操作记详细信息")
    public RestResult pageById(@PathVariable Integer id) {
        return RestResult.ok(operationLogService.getById(id));
    }

}
